var app = getApp();
Page({
  data: {
    isLoading: !0,
    boo: !1,
    proList: "",
    maBoo: !0,
    noFlag: !1,
    neworder:[],
    imageArr: [],
    bigMask: false,
    footer: {
      footerTab: 3,
      footerlist: [{
        text: "首页",
        img: "/hyb_yl/images/tab01.png",
        selimg: "/hyb_yl/images/tab1.png",
        url: "/hyb_yl/tabBar/index/index"
      }, {
        text: "资讯",
        img: "/hyb_yl/images/tab02.png",
        selimg: "/hyb_yl/images/tab2.png",
        url: "/hyb_yl/tabBar/jibingyufang/jibingyufang"
      }, {
        text: "分享",
        img: "/hyb_yl/images/tab03.png",
        selimg: "/hyb_yl/images/tab3.png",
        url: "/hyb_yl/tabBar/community/community"
      }, {
        text: "药房",
        img: "/hyb_yl/images/tab04.png",
        selimg: "/hyb_yl/images/tab4.png",
        url: "/hyb_yl/tabBar/shop/shop"
      }, {
        text: "问诊",
        img: "/hyb_yl/images/tab04.png",
        selimg: "/hyb_yl/images/tab4.png",
        url: "/hyb_yl/tabBar/fastnavigate/fastnavigate"
      }, {
        text: "我的",
        img: "/hyb_yl/images/tab05.png",
        selimg: "/hyb_yl/images/tab5.png",
        url: "/hyb_yl/tabBar/my/my"
      }]
    },
    neworder:[{}],
  },
  goback:function(e){
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/shopType/shopType?fid=0',
    })
  },
  onLoad: function (options ) {
    this.getfooter()
    wx.createCanvasContext("myQrcode");
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var index = options.index
    this.setData({
      backgroundColor: bgc,
      index: index
    })
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/index.neworder',
      data: {
        type: 'goods'
      },
      success: function (res) {
        that.setData({
          neworder: res.data
        })
      },
      fail: function (err) {
        
      },
    })
  },
  ma: function () {
    var t = !this.data.maBoo;
    this.setData({
      maBoo: t
    }), drawQrcode({
      width: 200,
      height: 200,
      canvasId: "myQrcode",
      text: "15210865395"
    });
  },
  onShareAppMessage: function (t) {
    return a.globalData.share;
  },
  onShow: function () {
    this.getBase()
    this.getallgoods()
    var that = this
    var openid = wx.getStorageSync('openid')
    console.log(openid)
    if (openid) {
      that.setData({
        bigMask: true
      })
    } else {
      that.setData({
        bigMask: false
      })
    }
    
  },
  onReady: function () {
    this.getallgoods()
    this.getBase()
  },
  onPullDownRefresh: function () {
    var that = this;
    wx.showNavigationBarLoading(), app.util.request({
      url: "entry/wxapp/goods.listgoods",
      success: function (res) {
        console.log(res)
        var proList = res.data
        that.setData({
          proList: proList
        })
      },
    });
  },
  getallgoods: function () {
    var that = this
    app.util.request({
      url: "entry/wxapp/goods.listgoods",
      success: function (res) {
        console.log(res)
        var proList = res.data
        that.setData({
          proList: proList,
          isLoading: !1,
        })
      },
    });
  },
  getBase: function () {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/index.adv',
      'cachetime': '30',
      data:{
        position:19
      },
      success: function (res) {
        console.log(res)
        var imageArr = res.data
        that.setData({
          imageArr: imageArr
        })
      }
    })
  },
  toast: function () {
    wx.redirectTo({
      url: '/hyb_yl/tabBar/index/index'
    })
  },
  toast1: function (e) {
    //console.log(e)
    wx.redirectTo({
      url: '/hyb_yl/tabBar/community/community'
    })
  },
  toast2: function () {
    wx.redirectTo({
      url: '/hyb_yl/mysubpages/pages/shop/shop'
    })
  },
  toast3: function () {
    wx.redirectTo({
      url: '/hyb_yl/tabBar/my/my'
    })
  },
  toast4() {
    wx.redirectTo({
      url: '/hyb_yl/userLife/pages/jibingyufang/jibingyufang?biaoti2=资讯'
    })
  },
  getfooter() {
    var that = this
    app.util.request({
      url: "entry/wxapp/index.footerlist",
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function (resing) {
        let footers = {
          footerTab: that.data.index,
          footerlist: resing.data
        };
        that.setData({
          footer: footers
        })
      }
    })
  },
});